package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.AgingLedgerForFinance;
import com.sl.au.entity.EXDEPayAgingAccountInfo;
import com.sl.au.repository.AgingLedgerForFinanceRepository;
import com.sl.au.service.AgingLedgerForFinanceService;

@Service("AgingLedgerForFinanceService")
@Transactional
public class AgingLedgerForFinanceServiceImpl extends BaseServiceImpl implements AgingLedgerForFinanceService{

	@Autowired
	AgingLedgerForFinanceRepository agingLedgerForFinanceRepository;
	
	@Override
	public AgingLedgerForFinanceRepository getRepository() {
		// TODO Auto-generated method stub
		return this.agingLedgerForFinanceRepository;
	}

	@Override
	public List<AgingLedgerForFinance> getMyPage(int start, int length, String superior, String key) {
		Page<AgingLedgerForFinance> pages=null;
		Pageable pageable=new PageRequest(start/length,length,Sort.Direction.DESC,"cdutyOfficer");//排序
		if(key != null && !key.equals("")){
			pages=agingLedgerForFinanceRepository.getexdePayAgingAccountInfo(superior,key,pageable);//注意顺序
		}else{
			pages=agingLedgerForFinanceRepository.getexdePayAgingAccountInfo(superior,pageable);
		}
		return pages.getContent();
	}

	@Override
	public long getCount(int length, int length2, String superior, String key) {
		long pagesCount = 0;
		if(key != null && !key.equals("")){
			pagesCount = agingLedgerForFinanceRepository.getCount(superior,key);//注意顺序
		}else{
			pagesCount = agingLedgerForFinanceRepository.getCount(superior);
		}
		
		return pagesCount;
	}

}
